<template>
  <div class="details">
    <div class="headerBj"></div>
    <div class="content">
      <div class="desc">
        <div class="title">
          <div class="ftitle">{{ details.ftitle }}</div>
          <div class="gx">更新中</div>
          <div class="collect" :class="details.collect ? 'active' : ''" @click="collectChange(details)">
            {{ details.collect ? "已收藏" : "收藏" }}
          </div>
        </div>
        <div class="text">
          <span>介绍：{{ details.present }}</span>
          <span>受众人群：{{ details.people }}</span>
          <span>能够获得什么：{{ details.decs }}</span>
        </div>
        <div class="floor1">
          <div class="left">
            <div class="floor1Item" v-for="(item, index) in data" :key="index">
              <span class="value">{{ item.value }}</span>

              <span class="tit">{{ item.tit }}</span>
            </div>
          </div>
          <div class="right">
            <el-button type="success" round>开始学习</el-button>
          </div>
        </div>
        <div class="floor2">
          <div class="floor2Item">
            <el-card class="box-card">
              <div slot="header" class="clearfix">
                <span>第一课时</span>
              </div>
              <div class="floor2content text">
                <div class="floor2left">
                    <img :src="details.image" width="300px" height="150px"  alt="">
                </div>
                <div class="floor2right">
                    <span>难度：新手入门</span>
                    <span>学习人数：35万</span>
                    <span>一节课：45分钟</span>
                    <el-button type="success" round>开始学习</el-button>
                </div>
              </div>
            </el-card>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  computed: {
    ...mapState(["details"]),
  },
  data() {
    return {
      data: [
        {
          tit: "课时",
          value: "1个",
        },
        {
          tit: "人已学习",
          value: "35万",
        },
        {
          tit: "配套练习",
          value: "1节",
        },
        {
          tit: "每天学一节课",
          value: "免费",
        },
      ],
    };
  },
  methods: {
    collectChange(e) {
        let a = !e.collect
        if(a){
            this.$message({
                message: "收藏成功",
                type: "success",
              });
        }else{
            this.$message({
                message: "取消收藏",
                type: "warning",
              });
        }
        this.$store.dispatch('Curriculum',{id:e.id,collect:a})
    }
  },
};
</script>

<style lang="scss" scoped>
.details {
  width: 100%;
  position: relative;
  .headerBj {
    width: 100%;
    height: 200px;
    background-image: url("../../assets/bj.png");
    background-size: 100% 100%;
  }
  .content {
    width: 1100px;
    position: absolute;
    left: 50%;
    top: 0px;
    transform: translateX(-50%);
    padding: 15px 0px;
    box-sizing: border-box;
    color: #fff;
    font-family: "楷体";
    .desc {
      width: 100%;
      // height: 160px;
      // background-color: red;
      .title {
        display: flex;
        align-items: center;
        margin-bottom: 20px;
        height: 30px;
        > div {
          margin-right: 20px;
          cursor: pointer;
        }
        .ftitle {
          font-size: 20px;
          font-weight: 700px;
        }
        .gx {
          border: 1px solid #fff;
          padding: 2px 6px;
          border-radius: 4px;
        }
        .collect {
          border: 1px solid #fff;
          padding: 2px 6px;
          border-radius: 4px;
          transition: color 0.3s;
          &:hover {
            transform: scale(1.05); /* 缩放效果 */
          }
        }
        .active {
          border: none;
          padding: 2px 6px;
          border-radius: 4px;
          background-color: #fa5151;
        }
      }
      .text {
        // background: red;
        width: 100%;
        height: 100px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
      }
    }
  }
  .floor1 {
    margin-top: 10px;
    width: 100%;
    height: 60px;
    background: #fff;
    box-shadow: 0px 0px 5px 5px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #000;
    padding: 0 20px;
    box-sizing: border-box;
    .left {
      width: 65%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .value {
        font-weight: 600;
        font-size: 18px;
        color: #ddd687;
      }
    }
    .right {
      width: 20%;
      display: flex;
      justify-content: center;
    }
  }
  .floor2 {
    margin-top: 20px;
    width: 100%;
    padding: 20px 200px;
    box-sizing: border-box;
    background: #fff;
    box-shadow: 0px 0px 5px 5px rgba(0, 0, 0, 0.2);
    .floor2content{
        height: 150px !important;
        display: flex !important;
        flex-direction:inherit !important;
        justify-content: start !important;
        .floor2right{
            display: flex;
            flex-direction: column;
            padding: 10px 20px;
            box-sizing: border-box;
            // margin-left: 20px;
            >span{
                margin-bottom: 10px;
            }
        }
    }
  }
}
</style>
